package com.oauth2.springsecurityoauth2demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * JwtToken 配置类
 * @author wangning
 * @create 2021-03-31 20:44
 */
@Configuration
public class JwtTokenStoreConfig {

	@Bean
	public TokenStore jwtTokenStore() {
		return new JwtTokenStore(jwtAccessTokenConverter());
	}

	@Bean
	public JwtAccessTokenConverter jwtAccessTokenConverter() {
		JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
		//配置jwt使用的秘钥
		jwtAccessTokenConverter.setSigningKey("test_key");
		return jwtAccessTokenConverter;
	}

	@Bean
	public JwtTokenEnhancer getJwtTokenEnhancer() {
		return new JwtTokenEnhancer();
	}
}
